using System;
using NUnit.Framework;
using dnA.Math;

namespace dnA.dnAtests.Math 
{
	[TestFixture]
	public class ComplexMath_Float_AbsoluteTest
	{
		[Test]
		public void Absolute()
		{
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,1.19209289550780998537e-7f)), 1.19209289550780998537e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,-1.19209289550780998537e-7f)), 1.19209289550780998537e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,5.0e-1f)), 5.0e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,-5.0e-1f)), 5.0e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,1.0f)), 1.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,-1.0f)), 1.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,2.0f)), 2.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,-2.0f)), 2.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(0.0f,-8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,0.0f)), 1.19209289550780998537e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,0.0f)), 1.19209289550780998537e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,1.19209289550780998537e-7f)), 1.68587394043575771526e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,-1.19209289550780998537e-7f)), 1.68587394043575771526e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,1.19209289550780998537e-7f)), 1.68587394043575771526e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,-1.19209289550780998537e-7f)), 1.68587394043575771526e-7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,5.0e-1f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,-5.0e-1f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,5.0e-1f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,-5.0e-1f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,1.0f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,-1.0f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,1.0f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,-1.0f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,2.0f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,-2.0f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,2.0f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,-2.0f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.19209289550780998537e-7f,-8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.19209289550780998537e-7f,-8.388608e6f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,0.0f)), 5.0e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,0.0f)), 5.0e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,1.19209289550780998537e-7f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,-1.19209289550780998537e-7f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,1.19209289550780998537e-7f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,-1.19209289550780998537e-7f)), 5.00000000000014210855e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,5.0e-1f)), 7.07106781186547524401e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,-5.0e-1f)), 7.07106781186547524401e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,5.0e-1f)), 7.07106781186547524401e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,-5.0e-1f)), 7.07106781186547524401e-1, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,1.0f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,-1.0f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,1.0f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,-1.0f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,2.0f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,-2.0f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,2.0f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,-2.0f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,8.388608e6f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(5.0e-1f,-8.388608e6f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,8.388608e6f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-5.0e-1f,-8.388608e6f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,0.0f)), 1.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,0.0f)), 1.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,1.19209289550780998537e-7f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,-1.19209289550780998537e-7f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,1.19209289550780998537e-7f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,-1.19209289550780998537e-7f)), 1.00000000000000710543, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,5.0e-1f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,-5.0e-1f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,5.0e-1f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,-5.0e-1f)), 1.1180339887498948482, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,1.0f)), 1.4142135623730950488, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,-1.0f)), 1.4142135623730950488, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,1.0f)), 1.4142135623730950488, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,-1.0f)), 1.4142135623730950488, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,2.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,-2.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,2.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,-2.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,8.388608e6f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(1.0f,-8.388608e6f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,8.388608e6f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-1.0f,-8.388608e6f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,0.0f)), 2.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,0.0f)), 2.0, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,1.19209289550780998537e-7f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,-1.19209289550780998537e-7f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,1.19209289550780998537e-7f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,-1.19209289550780998537e-7f)), 2.00000000000000355271, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,5.0e-1f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,-5.0e-1f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,5.0e-1f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,-5.0e-1f)), 2.06155281280883027491, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,1.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,-1.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,1.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,-1.0f)), 2.23606797749978969641, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,2.0f)), 2.8284271247461900976, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,-2.0f)), 2.8284271247461900976, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,2.0f)), 2.8284271247461900976, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,-2.0f)), 2.8284271247461900976, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,8.388608e6f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(2.0f,-8.388608e6f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,8.388608e6f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-2.0f,-8.388608e6f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,0.0f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,0.0f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,1.19209289550780998537e-7f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,-1.19209289550780998537e-7f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,1.19209289550780998537e-7f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,-1.19209289550780998537e-7f)), 8.388608e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,5.0e-1f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,-5.0e-1f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,5.0e-1f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,-5.0e-1f)), 8.38860800000001490116e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,1.0f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,-1.0f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,1.0f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,-1.0f)), 8.38860800000005960464e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,2.0f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,-2.0f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,2.0f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,-2.0f)), 8.38860800000023841858e6, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,8.388608e6f)), 1.18632832030314441111e7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(8.388608e6f,-8.388608e6f)), 1.18632832030314441111e7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,8.388608e6f)), 1.18632832030314441111e7, 1e-7f);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new ComplexFloat(-8.388608e6f,-8.388608e6f)), 1.18632832030314441111e7, 1e-7f);
		}
	}
}
